package com.sso.controller;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

public class BaseController {
    
      public static final String BEGIN_METHOD = "->  {}  method begin ";
      
      protected final String TICKET_GRANTING_TICKET_COOKIE_NAME = "tgc";
      
      protected final String CUST_NUM_COOKIE_NAME = "custno";
      
      protected final String AUTH_ID = "authId";
      
      protected String getCookieTGC(HttpServletRequest request)  {
          String authId = "";
          Cookie[] cookies = request.getCookies();
          if (null != cookies && cookies.length > 0) {
              for (Cookie cookie : cookies) {
                  if (cookie.getName().equals(TICKET_GRANTING_TICKET_COOKIE_NAME)) {
                      authId = cookie.getValue();
                  }
              }
          }
          return authId;
      }
      
      protected String getCookieCustNum(HttpServletRequest request)  {
          String custNum = "";
          Cookie[] cookies = request.getCookies();
          if (null != cookies && cookies.length > 0) {
              for (Cookie cookie : cookies) {
                  if (cookie.getName().equals(CUST_NUM_COOKIE_NAME)) {
                	  custNum = cookie.getValue();
                  }
              }
          }
          return custNum;
      }
      
}
